<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Event Publisher</title>
    
    <link rel="stylesheet" type="text/css" media="screen" href="css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
    
    <style type="text/css">
	html, body {
	    margin: 10;
	    padding: 10;
	    font-size: 75%;
	}
	</style>
	    
    <!--  
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://jquery-json.googlecode.com/files/jquery.json-2.2.min.js"></script>
    -->
    <!--  
    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    -->
    
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.json-2.2.min.js"></script>
    
    <script type="text/javascript" src="js/i18n/grid.locale-en.js"></script>
	<script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
	
    <script type="text/javascript">
    jQuery(function($) {
        
        function processEvents2(events) {
        	for (var i in events) {
                $('#logs1').append('<span>[Complex Event Processing] Error Pattern was matched: error category [<span style="color: red;">' + events[i].errorCategory + '</span>],  matched Count [' + events[i].count + '], time stamp [' + events[i].timeStamp + ']</span><br/>');
                
             	// jquery grid
                var datarow = {errorCategory:events[i].errorCategory, count:events[i].count, timeStamp:events[i].timeStamp};
            	var su=jQuery("#list2").jqGrid('addRowData',i,datarow);
            }
        }

        function long_polling2() {
            $.getJSON('eventPublisher', function(events) {
                processEvents2(events);
                long_polling2();
            });
        }

        long_polling2();        
        
      	// jquery grid
        // eventPublisher
        $("#list2").jqGrid({        
           	url:'',
        	datatype: "json",
           	colNames:['errorCategory','count','timeStamp'],
           	//colNames:['no', 'loginUser'],
           	colModel:[
           		{name:'errorCategory',index:'errorCategory', width:200},
           		{name:'count',index:'count', width:200},
           		{name:'timeStamp',index:'timeStamp', width:330}
           	],
           	rowNum:10,
           	rowList:[10,20,30],
           	pager: '#pager2',
           	sortname: 'errorCategory',
            viewrecords: true,
            sortorder: "desc",
            caption:"Matched Error Patterns",
            //editurl:"someurl.php"
        }).navGrid("#pager2",{edit:false,add:false,del:false});

    });

    </script>
</head>
<body>
<table id="list2"><tr><td/></tr></table> 
<div id="pager2"></div>
</body>
</html>
